# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=jbigkit
pkgver=2.1
pkgrel=2
pkgdesc="Data compression library/utilities for bi-level high-resolution images"
url="http://www.cl.cam.ac.uk/~mgk25/jbigkit/"
arch="all"
license="GPL"
# test fails
options="!check"
makedepends="imagemagick-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="https://www.cl.cam.ac.uk/~mgk25/download/$pkgname-$pkgver.tar.gz"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	default_prepare
	cd "$builddir"
	unset CFLAGS CPPFLAGS LDFLAGS
	if [ "$CARCH" = "x86_64" ]; then
		export CFLAGS="$CFLAGS -fPIC"
	else
		export CFLAGS="$CFLAGS"
	fi
}

build() {
	cd "$builddir"
	make CFLAGS="$CFLAGS"
}

package() {
	cd "$builddir"
	install -D -m644 libjbig/libjbig.a "$pkgdir"/usr/lib/libjbig.a
	install -D -m644 libjbig/libjbig85.a "$pkgdir"/usr/lib/libjbig85.a
	install -D -m644 libjbig/jbig.h "$pkgdir"/usr/include/jbig.h
	install -D -m644 libjbig/jbig_ar.h "$pkgdir"/usr/include/jbig_ar.h
	install -D -m644 libjbig/jbig85.h "$pkgdir"/usr/include/jbig85.h
	install -D -m755 pbmtools/jbgtopbm "$pkgdir"/usr/bin/jbgtopbm
	install -D -m755 pbmtools/pbmtojbg "$pkgdir"/usr/bin/pbmtojbg
	install -D -m755 pbmtools/jbgtopbm85 "$pkgdir"/usr/bin/jbgtopbm85
	install -D -m755 pbmtools/pbmtojbg85 "$pkgdir"/usr/bin/pbmtojbg85
	install -d -m755 "$pkgdir"/usr/share/man/man1
	install -m644 pbmtools/*.1* "$pkgdir"/usr/share/man/man1
}

sha512sums="c4127480470ef90db1ef3bd2caa444df10b50ed8df0bc9997db7612cb48b49278baf44965028f1807a21028eb965d677e015466306b44683c4ec75a23e1922cf  jbigkit-2.1.tar.gz"
